package org.sunshine.miracle.ui;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.sunshine.miracle.model.VirtualFile;

public class FileInfoPanel {

    private Label nameLabel;
    private Label typeLabel;
    private Label pathLabel;

    public FileInfoPanel(Composite parent) {
        Composite composite = new Composite(parent, SWT.NONE);
//        composite.setBounds();
        GridLayout gridLayout = new GridLayout();
        gridLayout.numColumns = 1;
        gridLayout.marginHeight = gridLayout.marginWidth = 5;
        gridLayout.horizontalSpacing = gridLayout.verticalSpacing = 2;


        composite.setLayout(gridLayout);


        nameLabel = SWTUtils.createLabel(composite, SWT.WRAP);
        nameLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL));

        typeLabel = SWTUtils.createLabel(composite, SWT.WRAP);
        typeLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL));

        pathLabel = SWTUtils.createLabel(composite, SWT.WRAP);
        pathLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL));


    }

    public void setFileInfo(VirtualFile virtualFile){
        nameLabel.setText(virtualFile.getName());
        if (virtualFile.isVirtual()){
            typeLabel.setText(StringBundle.getResourceString("file.info.virtual_folder"));    
        }else {
            typeLabel.setText(StringBundle.getResourceString("file.info.file"));            
        }

        if (!virtualFile.isVirtual()){
            pathLabel.setText(virtualFile.getAbsolutePath());
        }else{
            pathLabel.setText("");
        }

    }


    public void clearInfo() {
        nameLabel.setText("");
        typeLabel.setText("");
        pathLabel.setText("");
    }
}
